In [1]:
from __future__ import print_function, division

In [2]:
# This changes the current directory to the base saga directory - make sure to run this first!
# This is necessary to be able to import the py files and use the right directories,
# while keeping all the notebooks in their own directory.
import os
import sys
from time import time

if 'saga_base_dir' not in locals():
    saga_base_dir = os.path.abspath('..')
if saga_base_dir not in sys.path:
    os.chdir(saga_base_dir)

In [3]:
import hosts
import targeting

import numpy as np

from scipy import interpolate

from astropy import units as u
from astropy.coordinates import SkyCoord
from astropy import table
from astropy.table import Table
from astropy.io import fits

from astropy.utils.console import ProgressBar

from collections import Counter

In [4]:
%matplotlib inline
from matplotlib import style, pyplot as plt

plt.style.use('seaborn-deep')
plt.rcParams['image.cmap'] = 'viridis'
plt.rcParams['image.origin'] = 'lower'
plt.rcParams['figure.figsize'] = (14, 8)
plt.rcParams['axes.titlesize'] =  plt.rcParams['axes.labelsize'] = 16
plt.rcParams['xtick.labelsize'] =  plt.rcParams['ytick.labelsize'] = 14

In [5]:
from IPython import display

In [6]:
from decals import make_cutout_comparison_table, fluxivar_to_mag_magerr, compute_sb, DECALS_AP_SIZES, subselect_aperture

Get AnaK/brick info


In [7]:
hsts = hosts.get_saga_hosts_from_google(clientsecretjsonorfn='client_secrets.json', useobservingsummary=False)
anak  = [h for h in hsts if h.name=='AnaK']
assert len(anak)==1
anak = anak[0]


Using cached version of google hosts list from file "hosts_dl.pkl2"

In [8]:
bricknames = []
with open('decals_dr3/anakbricks') as f:
    for l in f:
        l = l.strip()
        if l != '':
            bricknames.append(l)
print(bricknames)


['3538m007', '3541m007', '3543m007', '3546m007', '3533m005', '3536m005', '3538m005', '3541m005', '3543m005', '3546m005', '3548m005', '3531m002', '3533m002', '3536m002', '3538m002', '3541m002', '3543m002', '3546m002', '3548m002', '3551m002', '3531p000', '3533p000', '3536p000', '3538p000', '3541p000', '3543p000', '3546p000', '3548p000', '3551p000', '3531p002', '3533p002', '3536p002', '3538p002', '3541p002', '3543p002', '3546p002', '3548p002', '3551p002', '3531p005', '3533p005', '3536p005', '3538p005', '3541p005', '3543p005', '3546p005', '3548p005', '3551p005', '3531p007', '3533p007', '3536p007', '3538p007', '3541p007', '3543p007', '3546p007', '3548p007', '3551p007', '3533p010', '3536p010', '3538p010', '3541p010', '3543p010', '3546p010', '3548p010', '3536p012', '3538p012', '3541p012', '3543p012', '3546p012']

Download the catalogs if needed


In [9]:
base_url = 'http://portal.nersc.gov/project/cosmo/data/legacysurvey/dr3/tractor/{first3}/tractor-{brickname}.fits'

for brickname in ProgressBar(bricknames, ipython_widget=True):
    url = base_url.format(brickname=brickname, first3=brickname[:3])
    target = os.path.join('decals_dr3/catalogs/', url.split('/')[-1])
    if not os.path.isfile(target):
        !wget $url -O $target
    else:
        print(target, 'already exists, not downloading')


decals_dr3/catalogs/tractor-3538m007.fits already exists, not downloading
decals_dr3/catalogs/tractor-3541m007.fits already exists, not downloading
decals_dr3/catalogs/tractor-3543m007.fits already exists, not downloading
decals_dr3/catalogs/tractor-3546m007.fits already exists, not downloading
decals_dr3/catalogs/tractor-3533m005.fits already exists, not downloading
decals_dr3/catalogs/tractor-3536m005.fits already exists, not downloading
decals_dr3/catalogs/tractor-3538m005.fits already exists, not downloading
decals_dr3/catalogs/tractor-3541m005.fits already exists, not downloading
decals_dr3/catalogs/tractor-3543m005.fits already exists, not downloading
decals_dr3/catalogs/tractor-3546m005.fits already exists, not downloading
decals_dr3/catalogs/tractor-3548m005.fits already exists, not downloading
decals_dr3/catalogs/tractor-3531m002.fits already exists, not downloading
decals_dr3/catalogs/tractor-3533m002.fits already exists, not downloading
decals_dr3/catalogs/tractor-3536m002.fits already exists, not downloading
decals_dr3/catalogs/tractor-3538m002.fits already exists, not downloading
decals_dr3/catalogs/tractor-3541m002.fits already exists, not downloading
decals_dr3/catalogs/tractor-3543m002.fits already exists, not downloading
decals_dr3/catalogs/tractor-3546m002.fits already exists, not downloading
decals_dr3/catalogs/tractor-3548m002.fits already exists, not downloading
decals_dr3/catalogs/tractor-3551m002.fits already exists, not downloading
decals_dr3/catalogs/tractor-3531p000.fits already exists, not downloading
decals_dr3/catalogs/tractor-3533p000.fits already exists, not downloading
decals_dr3/catalogs/tractor-3536p000.fits already exists, not downloading
decals_dr3/catalogs/tractor-3538p000.fits already exists, not downloading
decals_dr3/catalogs/tractor-3541p000.fits already exists, not downloading
decals_dr3/catalogs/tractor-3543p000.fits already exists, not downloading
decals_dr3/catalogs/tractor-3546p000.fits already exists, not downloading
decals_dr3/catalogs/tractor-3548p000.fits already exists, not downloading
decals_dr3/catalogs/tractor-3551p000.fits already exists, not downloading
decals_dr3/catalogs/tractor-3531p002.fits already exists, not downloading
decals_dr3/catalogs/tractor-3533p002.fits already exists, not downloading
decals_dr3/catalogs/tractor-3536p002.fits already exists, not downloading
decals_dr3/catalogs/tractor-3538p002.fits already exists, not downloading
decals_dr3/catalogs/tractor-3541p002.fits already exists, not downloading
decals_dr3/catalogs/tractor-3543p002.fits already exists, not downloading
decals_dr3/catalogs/tractor-3546p002.fits already exists, not downloading
decals_dr3/catalogs/tractor-3548p002.fits already exists, not downloading
decals_dr3/catalogs/tractor-3551p002.fits already exists, not downloading
decals_dr3/catalogs/tractor-3531p005.fits already exists, not downloading
decals_dr3/catalogs/tractor-3533p005.fits already exists, not downloading
decals_dr3/catalogs/tractor-3536p005.fits already exists, not downloading
decals_dr3/catalogs/tractor-3538p005.fits already exists, not downloading
decals_dr3/catalogs/tractor-3541p005.fits already exists, not downloading
decals_dr3/catalogs/tractor-3543p005.fits already exists, not downloading
decals_dr3/catalogs/tractor-3546p005.fits already exists, not downloading
decals_dr3/catalogs/tractor-3548p005.fits already exists, not downloading
decals_dr3/catalogs/tractor-3551p005.fits already exists, not downloading
decals_dr3/catalogs/tractor-3531p007.fits already exists, not downloading
decals_dr3/catalogs/tractor-3533p007.fits already exists, not downloading
decals_dr3/catalogs/tractor-3536p007.fits already exists, not downloading
decals_dr3/catalogs/tractor-3538p007.fits already exists, not downloading
decals_dr3/catalogs/tractor-3541p007.fits already exists, not downloading
decals_dr3/catalogs/tractor-3543p007.fits already exists, not downloading
decals_dr3/catalogs/tractor-3546p007.fits already exists, not downloading
decals_dr3/catalogs/tractor-3548p007.fits already exists, not downloading
decals_dr3/catalogs/tractor-3551p007.fits already exists, not downloading
decals_dr3/catalogs/tractor-3533p010.fits already exists, not downloading
decals_dr3/catalogs/tractor-3536p010.fits already exists, not downloading
decals_dr3/catalogs/tractor-3538p010.fits already exists, not downloading
decals_dr3/catalogs/tractor-3541p010.fits already exists, not downloading
decals_dr3/catalogs/tractor-3543p010.fits already exists, not downloading
decals_dr3/catalogs/tractor-3546p010.fits already exists, not downloading
decals_dr3/catalogs/tractor-3548p010.fits already exists, not downloading
decals_dr3/catalogs/tractor-3536p012.fits already exists, not downloading
decals_dr3/catalogs/tractor-3538p012.fits already exists, not downloading
decals_dr3/catalogs/tractor-3541p012.fits already exists, not downloading
decals_dr3/catalogs/tractor-3543p012.fits already exists, not downloading
decals_dr3/catalogs/tractor-3546p012.fits already exists, not downloading

Load the catalogs


In [10]:
bricks = Table.read('decals_dr3/survey-bricks.fits.gz')
bricksdr3 = Table.read('decals_dr3/survey-bricks-dr3.fits.gz')

In [11]:
catalog_fns = ['decals_dr3/catalogs/tractor-{}.fits'.format(bnm) for bnm in bricknames]
decals_catalogs = [Table.read(fn) for fn in catalog_fns]
dcatall = table.vstack(decals_catalogs, metadata_conflicts='silent')


WARNING: UnitsWarning: '1/deg^2' did not parse as fits unit: Numeric factor not supported by FITS [astropy.units.core]
WARNING:astropy:UnitsWarning: '1/deg^2' did not parse as fits unit: Numeric factor not supported by FITS
WARNING: UnitsWarning: 'nanomaggy' did not parse as fits unit: At col 0, Unit 'nanomaggy' not supported by the FITS standard.  [astropy.units.core]
WARNING:astropy:UnitsWarning: 'nanomaggy' did not parse as fits unit: At col 0, Unit 'nanomaggy' not supported by the FITS standard. 
WARNING: UnitsWarning: '1/nanomaggy^2' did not parse as fits unit: Numeric factor not supported by FITS [astropy.units.core]
WARNING:astropy:UnitsWarning: '1/nanomaggy^2' did not parse as fits unit: Numeric factor not supported by FITS
WARNING: UnitsWarning: '1/arcsec^2' did not parse as fits unit: Numeric factor not supported by FITS [astropy.units.core]
WARNING:astropy:UnitsWarning: '1/arcsec^2' did not parse as fits unit: Numeric factor not supported by FITS

In [12]:
sdss_catalog = Table.read('catalogs/base_sql_nsa{}.fits.gz'.format(anak.nsaid))

Quickly Examine the catalogs


In [13]:
plt.scatter(dcatall['ra'], dcatall['dec'], lw=0, c='g', s=2, alpha=.25)
plt.scatter(sdss_catalog['ra'], sdss_catalog['dec'], lw=0, c='r', s=2, alpha=.25)

csize = 1*u.deg
phase = np.arange(360)*u.deg
xc = anak.coords.ra + csize * np.sin(phase)
yc = anak.coords.dec + csize * np.cos(phase)
plt.plot(xc, yc, lw=2, c='k')


Out[13]:
[<matplotlib.lines.Line2D at 0x1360c8dd0>]

In [14]:
#cut out the non-overlap region
dsc = SkyCoord(dcatall['ra'], dcatall['dec'], unit=u.deg)
dcutall = dcatall[dsc.separation(anak.coords) < 1*u.deg]

plt.scatter(dcutall['ra'], dcutall['dec'], lw=0, c='g', s=2, alpha=.25)
plt.scatter(sdss_catalog['ra'], sdss_catalog['dec'], lw=0, c='r', s=2, alpha=.25)


Out[14]:
<matplotlib.collections.PathCollection at 0x1671c5390>

Not the over-density in the brick boundaries. I think that's because the bricks have a bit of overlap. Could cut that to get the statistics right if necessary, but for now will leave it in for simplicity.

Galaxy detection depth


In [15]:
maggaldepth = -2.5*(np.log10(5*dcutall['decam_galdepth']**-0.5)-9)
maggaldepthr = maggaldepth[:, 2]


/Users/erik/miniconda3/envs/saga/lib/python2.7/site-packages/ipykernel/__main__.py:1: RuntimeWarning: divide by zero encountered in power
  if __name__ == '__main__':

In [16]:
plt.figure()
plt.hist(maggaldepthr[np.isfinite(maggaldepthr)], bins=100, histtype='step', log=False)
plt.xlabel('galdepth in $r$')
plt.ylabel('$n$')
plt.tight_layout()
plt.xlim(22, 25.5)

plt.figure()
plt.hist(maggaldepthr[np.isfinite(maggaldepthr)], bins=100, histtype='step', log=True)
plt.xlabel('galdepth in $r$')
plt.ylabel('$n$')
plt.tight_layout()
plt.xlim(22, 25.5)


Out[16]:
(22, 25.5)

Populate additional info in the DECaLS tables

First check that photometric uncertainties look sensible


In [17]:
r, r_err = fluxivar_to_mag_magerr(dcutall['decam_flux'][:, 2], dcutall['decam_flux_ivar'][:, 2])


decals.py:88: RuntimeWarning: divide by zero encountered in log10
  mag = np.array(22.5 - 2.5*np.log10(flux))
decals.py:88: RuntimeWarning: invalid value encountered in log10
  mag = np.array(22.5 - 2.5*np.log10(flux))
/Users/erik/miniconda3/envs/saga/lib/python2.7/site-packages/astropy/units/quantity.py:885: RuntimeWarning: divide by zero encountered in power
  return super(Quantity, self).__pow__(other)

In [18]:
plt.hexbin(r, r_err, extent=(15,26,0,1), bins='log',gridsize=200)


Out[18]:
<matplotlib.collections.PolyCollection at 0x160ce4850>

In [19]:
H, xe, ye = np.histogram2d(r, r_err, bins=200, range=((15,26),(0,1)))
lH = np.log(H)
lH[~np.isfinite(lH)] = np.min(lH[np.isfinite(lH)])-1
plt.pcolor(xe, ye, lH.T)
plt.xlim(15, 26)


/Users/erik/miniconda3/envs/saga/lib/python2.7/site-packages/numpy/lib/function_base.py:804: RuntimeWarning: invalid value encountered in greater_equal
  not_smaller_than_edge = (sample[:, i] >= edges[i][-1])
/Users/erik/miniconda3/envs/saga/lib/python2.7/site-packages/ipykernel/__main__.py:2: RuntimeWarning: divide by zero encountered in log
  from ipykernel import kernelapp as app
Out[19]:
(15, 26)

Convenient photometric measurements


In [20]:
for dcat in [dcutall]:
    for magnm, idx in zip('grz', [1, 2, 4]):
        mag, mag_err = fluxivar_to_mag_magerr(dcat['decam_flux'][:, idx], dcat['decam_flux_ivar'][:, idx])
        dcat[magnm] = mag
        dcat[magnm + '_err'] = mag_err
    
    dcat['sb_r_0.5'] = compute_sb(0.5*u.arcsec, dcat['decam_apflux'][:, 2, :])
    dcat['sb_r_0.75'] = compute_sb(0.75*u.arcsec, dcat['decam_apflux'][:, 2, :])
    dcat['sb_r_1'] = compute_sb(1.0*u.arcsec, dcat['decam_apflux'][:, 2, :])
    dcat['sb_r_2'] = compute_sb(2.0*u.arcsec, dcat['decam_apflux'][:, 2, :])


decals.py:109: RuntimeWarning: divide by zero encountered in log10
  return np.array(22.5 - 2.5*np.log10(apflux) + A) * u.mag * u.arcsec**-2
decals.py:109: RuntimeWarning: invalid value encountered in log10
  return np.array(22.5 - 2.5*np.log10(apflux) + A) * u.mag * u.arcsec**-2

Compute SDSS-like SB's

Details outlined in "DECALS low-SB_completeness figures" notebook


In [21]:
dcat = dcutall
rap_fluxes = dcat['decam_apflux'][:, 2, :]

expflux_r = np.empty_like(rap_fluxes[:, 0])
rad = np.empty(len(rap_fluxes[:, 0]))
ap_sizesv = DECALS_AP_SIZES.to(u.arcsec).value

intr = interpolate.BarycentricInterpolator(ap_sizesv, [0]*len(ap_sizesv))
for i in ProgressBar(range(len(rap_fluxes)), ipython_widget=True):
    f = rap_fluxes[i]
    if dcat['type'][i] == 'PSF ':
        r = dcat['decam_psfsize'][i, 2]
    elif dcat['type'][i] == 'DEV ':
        r = dcat['shapeDev_r'][i]
    else:
        r = dcat['shapeExp_r'][i]

    intr.set_yi(f)
    expflux_r[i] = intr(r)
    rad[i] = r

dcat['sdss_like_sb_r'] = compute_sb(rad*u.arcsec, np.array(expflux_r))



decals.py:108: RuntimeWarning: divide by zero encountered in log10
  A = 2.5*np.log10(np.pi*(rad.to(u.arcsec).value)**2)

X-matching catalogs


In [22]:
dsc = SkyCoord(dcutall['ra'], dcutall['dec'], unit=u.deg)
ssc = SkyCoord(sdss_catalog['ra'], sdss_catalog['dec'], unit=u.deg)
threshold = 1*u.arcsec

In [23]:
idx, d2d, _ = ssc.match_to_catalog_sky(dsc)
plt.hist(d2d.arcsec, bins=100, range=(0, 3),histtype='step', log=True)
plt.axvline(threshold.to(u.arcsec).value, c='k')
None



In [24]:
dmatchmsk = idx[d2d<threshold]
dmatch = dcutall[dmatchmsk]

smatch = sdss_catalog[d2d<threshold]

In [25]:
idx, d2d, _ = dsc.match_to_catalog_sky(ssc)
dnomatchmsk = d2d>threshold
dnomatch = dcutall[dnomatchmsk]

Sanity check that the no-match objects have no nearby companions, and the matches all do


In [26]:
idx, d2d, _ = ssc.match_to_catalog_sky(dsc[dnomatchmsk])
plt.hist(d2d.arcsec, bins=100, range=(0, 3),histtype='step', log=True)
plt.axvline(1.0, c='k')
None



In [27]:
idx, d2d, _ = dsc[dmatchmsk].match_to_catalog_sky(ssc)
plt.hist(d2d.arcsec, bins=100, range=(0, 3),histtype='step', log=True)
plt.axvline(1.0, c='k')
None


0.5" Aperture-based SB


In [28]:
plt.figure(figsize=(12, 10))

xnm = 'r'
ynm = 'sb_r_0.5'

dmextinction = -2.5*np.log10(dmatch['decam_mw_transmission'][:, 2])
x = dmatch[xnm] - dmextinction
y = dmatch[ynm] - dmextinction
dstar = dmatch['type']=='PSF '
sstar = smatch['phot_sg']==6

plt.scatter(x[~dstar&~sstar], y[~dstar&~sstar], c='b', lw=0, alpha=.4, s=2, label='Glx in Both')
plt.scatter(x[dstar&~sstar], y[dstar&~sstar], c='r', lw=0, alpha=.5, s=3, label='Star in DECaLS, Glx in SDSS')
plt.scatter(x[~dstar&sstar], y[~dstar&sstar], c='g', lw=0, alpha=.75, s=5, label='Glx in DECaLS, Star in SDSS')

dnstar = dnomatch['type']=='PSF '
dnoext = -2.5*np.log10(dnomatch['decam_mw_transmission'][:, 2])
plt.scatter((dnomatch[xnm] - dnoext)[~dnstar], (dnomatch[ynm] - dnoext)[~dnstar], 
            c='k', lw=0, alpha=.4, s=2, label='Glx in DECALS, not in SDSS')

#plt.hlines(24.5, 17, 21, colors='k', linestyles='--')
plt.axvline(20.75, color='k', ls=':')

plt.xlim(17, 24.5)
plt.ylim(18, 28)

plt.xlabel(r'$r_{0, {\rm DECaLS}}$', fontsize=28)
plt.ylabel(r'$SB_{0.5^{\prime \prime}, {\rm DECaLS}}$', fontsize=28)
plt.xticks(fontsize=24)
plt.yticks(fontsize=24)

plt.legend(loc='lower right', fontsize=20)
#plt.savefig(os.environ['HOME'] + '/Desktop/fig_decals.pdf')


Out[28]:
<matplotlib.legend.Legend at 0x1b497b790>

Galaxies in DECaLS w/ low SB


In [29]:
to_check = dcutall[(dcutall['r']<21)&(dcutall['sb_r_0.5']>24.5) & (dcutall['type']!='PSF ')]

np.random.shuffle(to_check)
print('n=', len(to_check))
make_cutout_comparison_table(to_check[:25])


n= 413
put this into http://skyserver.sdss.org/dr13/en/tools/chart/listinfo.aspx
name ra dec
('3538m007_5579', 353.95201933554904, -0.66210732760978153)
('3538m007_5579', 353.95201933554904, -0.66210732760978153)
('3538m007_5579', 353.95201933554904, -0.66210732760978153)
('3543m007_6426', 354.4683902955399, -0.63740493028302347)
('3536m005_1454', 353.65908980532021, -0.5668393371752668)
('3536m005_5262', 353.52738728616652, -0.4357397830214737)
('3536m005_5262', 353.52738728616652, -0.4357397830214737)
('3533m005_5486', 353.45114177314747, -0.41087886344046981)
('3543m007_6426', 354.4683902955399, -0.63740493028302347)
('3536m005_1454', 353.65908980532021, -0.5668393371752668)
('3536m005_5262', 353.52738728616652, -0.4357397830214737)
('3536m005_1454', 353.65908980532021, -0.5668393371752668)
('3536m005_5262', 353.52738728616652, -0.4357397830214737)
('3541m005_788', 354.19435059449091, -0.60015289685705653)
('3543m007_6426', 354.4683902955399, -0.63740493028302347)
('3538m007_5579', 353.95201933554904, -0.66210732760978153)
('3541m007_5058', 354.18007956779104, -0.68427285196923848)
('3538m005_203', 353.85391531907652, -0.62052438849368974)
('3543m007_6426', 354.4683902955399, -0.63740493028302347)
('3538m005_238', 353.85130187447254, -0.61899864359510737)
('3541m005_2262', 354.11925318274962, -0.5393922984588132)
('3541m005_1972', 354.06899033388902, -0.55629070449029805)
('3541m005_2263', 354.12113288489263, -0.54344454704168654)
('3543m005_30', 354.46527246733439, -0.63055363015307908)
('3541m007_5058', 354.18007956779104, -0.68427285196923848)
/Users/erik/miniconda3/envs/saga/lib/python2.7/site-packages/ipykernel/__main__.py:1: RuntimeWarning: invalid value encountered in less
  if __name__ == '__main__':
/Users/erik/miniconda3/envs/saga/lib/python2.7/site-packages/ipykernel/__main__.py:1: RuntimeWarning: invalid value encountered in greater
  if __name__ == '__main__':
Out[29]:
objDECALSSDSS
327463_5579
ra=353.952019336
dec=-0.66210732761
r=20.4786510468
sb_r_0.5=29.5524177551
decam_anymask=[0 1 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
327463_5579
ra=353.952019336
dec=-0.66210732761
r=20.4786510468
sb_r_0.5=29.5524177551
decam_anymask=[0 1 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
327463_5579
ra=353.952019336
dec=-0.66210732761
r=20.4786510468
sb_r_0.5=29.5524177551
decam_anymask=[0 1 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
327465_6426
ra=354.468390296
dec=-0.637404930283
r=19.7330684662
sb_r_0.5=24.743347168
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
328902_1454
ra=353.659089805
dec=-0.566839337175
r=20.7498130798
sb_r_0.5=26.3883342743
decam_anymask=[0 1 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
328902_5262
ra=353.527387286
dec=-0.435739783021
r=20.9407749176
sb_r_0.5=25.0238399506
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
328902_5262
ra=353.527387286
dec=-0.435739783021
r=20.9407749176
sb_r_0.5=25.0238399506
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
328901_5486
ra=353.451141773
dec=-0.41087886344
r=20.3377037048
sb_r_0.5=25.307559967
decam_anymask=[0 0 1 0 0 0]
decam_allmask=[0 0 0 0 0 0]
327465_6426
ra=354.468390296
dec=-0.637404930283
r=19.7330684662
sb_r_0.5=24.743347168
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
328902_1454
ra=353.659089805
dec=-0.566839337175
r=20.7498130798
sb_r_0.5=26.3883342743
decam_anymask=[0 1 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
328902_5262
ra=353.527387286
dec=-0.435739783021
r=20.9407749176
sb_r_0.5=25.0238399506
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
328902_1454
ra=353.659089805
dec=-0.566839337175
r=20.7498130798
sb_r_0.5=26.3883342743
decam_anymask=[0 1 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
328902_5262
ra=353.527387286
dec=-0.435739783021
r=20.9407749176
sb_r_0.5=25.0238399506
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
328904_788
ra=354.194350594
dec=-0.600152896857
r=19.7388954163
sb_r_0.5=27.0378456116
decam_anymask=[0 0 0 0 1 0]
decam_allmask=[0 0 0 0 0 0]
327465_6426
ra=354.468390296
dec=-0.637404930283
r=19.7330684662
sb_r_0.5=24.743347168
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
327463_5579
ra=353.952019336
dec=-0.66210732761
r=20.4786510468
sb_r_0.5=29.5524177551
decam_anymask=[0 1 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
327464_5058
ra=354.180079568
dec=-0.684272851969
r=20.9827136993
sb_r_0.5=24.8508205414
decam_anymask=[0 0 0 0 1 0]
decam_allmask=[0 0 0 0 0 0]
328903_203
ra=353.853915319
dec=-0.620524388494
r=20.5364818573
sb_r_0.5=25.1013851166
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
327465_6426
ra=354.468390296
dec=-0.637404930283
r=19.7330684662
sb_r_0.5=24.743347168
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
328903_238
ra=353.851301874
dec=-0.618998643595
r=20.8043384552
sb_r_0.5=26.5059967041
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
328904_2262
ra=354.119253183
dec=-0.539392298459
r=20.1842708588
sb_r_0.5=29.6684169769
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
328904_1972
ra=354.068990334
dec=-0.55629070449
r=18.7925300598
sb_r_0.5=24.7509078979
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
328904_2263
ra=354.121132885
dec=-0.543444547042
r=19.6181583405
sb_r_0.5=25.1243267059
decam_anymask=[0 0 0 0 1 0]
decam_allmask=[0 0 0 0 0 0]
328905_30
ra=354.465272467
dec=-0.630553630153
r=20.0577316284
sb_r_0.5=25.1306266785
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
327464_5058
ra=354.180079568
dec=-0.684272851969
r=20.9827136993
sb_r_0.5=24.8508205414
decam_anymask=[0 0 0 0 1 0]
decam_allmask=[0 0 0 0 0 0]

Galaxies in DECaLS, nothing in SDSS


In [30]:
to_check = dnomatch[((18<dnomatch['r']) & (dnomatch['r']<21) &
            (18<dnomatch['sb_r_0.5']) & (dnomatch['sb_r_0.5']<24.5) & 
            (dnomatch['type']!='PSF '))]

#np.random.shuffle(to_check)
print('n=', len(to_check))
make_cutout_comparison_table(to_check[:25])


n= 577
put this into http://skyserver.sdss.org/dr13/en/tools/chart/listinfo.aspx
name ra dec
('3538m007_6182', 353.85939158104185, -0.6372368577530042)
('3538m007_6193', 353.85717732548034, -0.62402973805574224)
('3541m007_6040', 354.0500732312201, -0.64881867151210415)
('3543m007_5830', 354.36418235490822, -0.66375713988331386)
('3543m007_5904', 354.26522375418733, -0.66039423037464695)
('3543m007_6369', 354.37663194293935, -0.6370344348652982)
('3536m005_4876', 353.62371768949697, -0.44037288628543092)
('3536m005_4881', 353.62368118766932, -0.43902954164562991)
('3536m005_5274', 353.67137064401822, -0.43109327934931535)
('3536m005_5275', 353.66876657252868, -0.42387943843620912)
('3536m005_5559', 353.51078868035916, -0.42065561161370707)
('3536m005_5733', 353.5117668570407, -0.41536700703989965)
('3536m005_5734', 353.54675766490931, -0.41422501816117685)
('3538m005_14', 353.85717707453995, -0.62402732701658159)
('3538m005_317', 353.8317562247509, -0.61466444579617263)
('3538m005_740', 353.99348487883816, -0.59518999321300448)
('3538m005_756', 353.99020313799252, -0.59542343223521266)
('3538m005_1076', 353.78462032144108, -0.57756053024888521)
('3538m005_2257', 353.87721212141349, -0.53093821607885561)
('3538m005_2633', 353.97642862010946, -0.51554756327510409)
('3538m005_4627', 353.79970059214213, -0.44670196011874513)
('3538m005_5538', 353.9421868569122, -0.40662774514549127)
('3538m005_5590', 353.88863676034623, -0.40497945625936815)
('3541m005_622', 354.10343514273097, -0.60407056882468635)
('3541m005_640', 354.22525351811709, -0.6039630785786464)
/Users/erik/miniconda3/envs/saga/lib/python2.7/site-packages/ipykernel/__main__.py:2: RuntimeWarning: invalid value encountered in greater
  from ipykernel import kernelapp as app
/Users/erik/miniconda3/envs/saga/lib/python2.7/site-packages/ipykernel/__main__.py:2: RuntimeWarning: invalid value encountered in less
  from ipykernel import kernelapp as app
Out[30]:
objDECALSSDSS
327463_6182
ra=353.859391581
dec=-0.637236857753
r=20.6315536499
sb_r_0.5=21.8978233337
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
327463_6193
ra=353.857177325
dec=-0.624029738056
r=20.9193935394
sb_r_0.5=22.4381694794
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
327464_6040
ra=354.050073231
dec=-0.648818671512
r=20.3428497314
sb_r_0.5=24.1732616425
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
327465_5830
ra=354.364182355
dec=-0.663757139883
r=18.8339614868
sb_r_0.5=21.7420368195
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
327465_5904
ra=354.265223754
dec=-0.660394230375
r=20.6401500702
sb_r_0.5=24.2276535034
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
327465_6369
ra=354.376631943
dec=-0.637034434865
r=18.4402656555
sb_r_0.5=23.8939743042
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
328902_4876
ra=353.623717689
dec=-0.440372886285
r=19.6901321411
sb_r_0.5=22.940990448
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
328902_4881
ra=353.623681188
dec=-0.439029541646
r=18.5703983307
sb_r_0.5=18.8021812439
decam_anymask=[ 0 194 70 0 70 0]
decam_allmask=[0 0 2 0 2 0]
328902_5274
ra=353.671370644
dec=-0.431093279349
r=19.8898715973
sb_r_0.5=23.7063312531
decam_anymask=[0 0 1 0 1 0]
decam_allmask=[0 0 0 0 0 0]
328902_5275
ra=353.668766573
dec=-0.423879438436
r=18.2946491241
sb_r_0.5=23.3222351074
decam_anymask=[ 0 0 0 0 68 0]
decam_allmask=[0 0 0 0 0 0]
328902_5559
ra=353.51078868
dec=-0.420655611614
r=20.6700191498
sb_r_0.5=21.9461956024
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
328902_5733
ra=353.511766857
dec=-0.41536700704
r=20.9496440887
sb_r_0.5=22.2618312836
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
328902_5734
ra=353.546757665
dec=-0.414225018161
r=20.5423965454
sb_r_0.5=23.0800895691
decam_anymask=[0 0 1 0 0 0]
decam_allmask=[0 0 0 0 0 0]
328903_14
ra=353.857177075
dec=-0.624027327017
r=20.8923339844
sb_r_0.5=22.5700187683
decam_anymask=[ 0 0 513 0 0 0]
decam_allmask=[0 0 0 0 0 0]
328903_317
ra=353.831756225
dec=-0.614664445796
r=19.0897006989
sb_r_0.5=23.9407215118
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
328903_740
ra=353.993484879
dec=-0.595189993213
r=20.576253891
sb_r_0.5=24.1129550934
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
328903_756
ra=353.990203138
dec=-0.595423432235
r=20.9305381775
sb_r_0.5=21.548910141
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
328903_1076
ra=353.784620321
dec=-0.577560530249
r=20.2244796753
sb_r_0.5=24.4344749451
decam_anymask=[0 0 1 0 0 0]
decam_allmask=[0 0 0 0 0 0]
328903_2257
ra=353.877212121
dec=-0.530938216079
r=20.8844795227
sb_r_0.5=24.3779029846
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
328903_2633
ra=353.97642862
dec=-0.515547563275
r=18.9745864868
sb_r_0.5=22.0614738464
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
328903_4627
ra=353.799700592
dec=-0.446701960119
r=20.2835483551
sb_r_0.5=24.2074928284
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
328903_5538
ra=353.942186857
dec=-0.406627745145
r=18.3210983276
sb_r_0.5=18.0172042847
decam_anymask=[ 0 0 70 0 70 0]
decam_allmask=[0 0 0 0 2 0]
328903_5590
ra=353.88863676
dec=-0.404979456259
r=20.5463161469
sb_r_0.5=18.9328136444
decam_anymask=[0 1 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
328904_622
ra=354.103435143
dec=-0.604070568825
r=19.5154838562
sb_r_0.5=21.9865493774
decam_anymask=[0 1 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
328904_640
ra=354.225253518
dec=-0.603963078579
r=19.181804657
sb_r_0.5=22.549451828
decam_anymask=[0 1 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]

inspect a couple of suspicious ones from the above list


In [31]:
msk = np.zeros(len(dnomatch), dtype=bool)
for nm in ['327464_6040', '327465_5904']:
    bid, oid = nm.split('_')
    msk |= ((dnomatch['objid']==int(oid))&(dnomatch['brickid']==int(bid)))
make_cutout_comparison_table(dnomatch[msk])


put this into http://skyserver.sdss.org/dr13/en/tools/chart/listinfo.aspx
name ra dec
('3541m007_6040', 354.0500732312201, -0.64881867151210415)
('3543m007_5904', 354.26522375418733, -0.66039423037464695)
Out[31]:
objDECALSSDSS
327464_6040
ra=354.050073231
dec=-0.648818671512
r=20.3428497314
sb_r_0.5=24.1732616425
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
327465_5904
ra=354.265223754
dec=-0.660394230375
r=20.6401500702
sb_r_0.5=24.2276535034
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]

In [32]:
dnomatch[msk]


Out[32]:
<Table length=2>
brickidbricknameobjidbrick_primaryblobninblobtycho2inblobtyperara_ivardecdec_ivarbxbybx0by0left_blobout_of_boundsdchisq [5]ebvcpu_sourcecpu_blobblob_widthblob_heightblob_npixblob_nimagesblob_totalpixdecam_flux [6]decam_flux_ivar [6]decam_apflux [6,8]decam_apflux_resid [6,8]decam_apflux_ivar [6,8]decam_mw_transmission [6]decam_nobs [6]decam_rchi2 [6]decam_fracflux [6]decam_fracmasked [6]decam_fracin [6]decam_anymask [6]decam_allmask [6]decam_psfsize [6]wise_flux [4]wise_flux_ivar [4]wise_mw_transmission [4]wise_nobs [4]wise_fracflux [4]wise_rchi2 [4]wise_lc_flux [2,5]wise_lc_flux_ivar [2,5]wise_lc_nobs [2,5]wise_lc_fracflux [2,5]wise_lc_rchi2 [2,5]wise_lc_mjd [2,5]fracDevfracDev_ivarshapeExp_rshapeExp_r_ivarshapeExp_e1shapeExp_e1_ivarshapeExp_e2shapeExp_e2_ivarshapeDev_rshapeDev_r_ivarshapeDev_e1shapeDev_e1_ivarshapeDev_e2shapeDev_e2_ivardecam_depth [6]decam_galdepth [6]gg_errrr_errzz_errsb_r_0.5sb_r_0.75sb_r_1sb_r_2sdss_like_sb_r
deg1/deg^2deg1/deg^2magnanomaggy1/nanomaggy^2nanomaggynanomaggy1/nanomaggy^2nanomaggy1/nanomaggy^2nanomaggy1/nanomaggy^2arcsec1/arcsec^2arcsec1/arcsec^21/nanomaggy^21/nanomaggy^2magmagmagmagmagmagmag / arcsec2mag / arcsec2mag / arcsec2mag / arcsec2mag / arcsec2
int32str8int32boolint32int16boolstr4float64float32float64float32float32float32float32float32boolboolfloat32float32float32float32int16int16int32int16int32float32float32float32float32float32float32uint8float32float32float32float32int16int16float32float32float32float32int16float32float32float32float32int16float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float64
3274643541m0076040True37158FalseCOMP354.0500732311.35905e+10-0.6488186715121.25872e+102828.963189.772829.03190.0FalseFalse609.314 .. 906.1170.035164126.9861.4691106562014774370.0 .. 0.00.0 .. 0.00.0 .. 0.00.0 .. 0.00.0 .. 0.00.878634 .. 0.9661270 .. 00.0 .. 0.00.0 .. 0.00.0 .. 0.00.0 .. 0.00 .. 00 .. 00.0 .. 0.0-2.78721 .. -195.8310.0349324 .. 1.69945e-060.994058 .. 0.99970543 .. 11152.844 .. 12.34252.67829 .. 0.0743816-10.579 .. 0.00.00978934 .. 0.011 .. 041.4314 .. 0.01.08654 .. 0.055363.2 .. 0.00.948541116213.00.239898285.376-0.0271338.72268-0.13031216.782869.6484384643.00.431524382012.00.700355383899.00.0 .. 0.00.0 .. 0.020.67680.054347620.34280.066043320.05680.1205724.173324.416524.697825.729623.9300013311
3274653543m0075904True35974FalseCOMP354.2652237546.9543e+09-0.6603942303756.83059e+093307.783030.713309.03030.0FalseFalse539.241 .. 1013.420.034023334.0260.857058215417277260.0 .. 0.00.0 .. 0.00.0 .. 0.00.0 .. 0.00.0 .. 0.00.882329 .. 0.9672080 .. 00.0 .. 0.00.0 .. 0.00.0 .. 0.00.0 .. 0.00 .. 00 .. 00.0 .. 0.0-15.8995 .. -1363.610.214986 .. 1.04542e-050.994251 .. 0.99971548 .. 151.8878 .. 1.084440.867013 .. 0.10772-9.26533 .. 0.00.0739965 .. 0.015 .. 03.10684 .. 0.00.598093 .. 0.055363.2 .. 0.00.089968628866.512.837215.19410.350409975.2880.6008921963.370.47131147.885-0.15811323.2190.27299930.05310.0 .. 0.00.0 .. 0.021.5880.070108320.64020.046824820.12650.073957924.227724.416724.537125.2418.0995303946

Both have anomalously large sizes... clearly they are not actually r<21

Gals in DECaLS, stars in SDSS


In [33]:
to_check = dmatch[~dstar&sstar&(dmatch['r']<21)]

np.random.shuffle(to_check)
print(len(to_check))
make_cutout_comparison_table(to_check[:25])


189
put this into http://skyserver.sdss.org/dr13/en/tools/chart/listinfo.aspx
name ra dec
('3541p002_325', 354.03025898351547, 0.13548504455171181)
('3543p002_2208', 354.25745988264481, 0.20117468627626303)
('3543p002_2208', 354.25745988264481, 0.20117468627626303)
('3538p002_4126', 353.89141051266841, 0.29414951798644906)
('3543p005_140', 354.35242845554717, 0.39355706821001407)
('3543p005_140', 354.35242845554717, 0.39355706821001407)
('3543p002_891', 354.39712825662468, 0.15469711454205362)
('3543p005_5058', 354.29234659072284, 0.57973710935990352)
('3543p002_2208', 354.25745988264481, 0.20117468627626303)
('3541p005_6383', 354.07374779178139, 0.61883639671651325)
('3543p005_140', 354.35242845554717, 0.39355706821001407)
('3543p002_2825', 354.47862096392572, 0.22631169717133032)
('3541p002_325', 354.03025898351547, 0.13548504455171181)
('3538p000_4208', 353.91058327695936, 0.034176422346735673)
('3543p005_140', 354.35242845554717, 0.39355706821001407)
('3541p005_3718', 354.13803283328946, 0.51820672535033363)
('3543p002_5297', 354.26968390028804, 0.31382117363150724)
('3538p000_4208', 353.91058327695936, 0.034176422346735673)
('3543p002_891', 354.39712825662468, 0.15469711454205362)
('3543p005_1294', 354.32111688199387, 0.43297017673232252)
('3538p000_4208', 353.91058327695936, 0.034176422346735673)
('3543p005_5058', 354.29234659072284, 0.57973710935990352)
('3543p005_530', 354.49370726665205, 0.38969498478637465)
('3538p000_4208', 353.91058327695936, 0.034176422346735673)
('3543p000_2853', 354.36221289281195, -0.0039100737243664141)
/Users/erik/miniconda3/envs/saga/lib/python2.7/site-packages/ipykernel/__main__.py:1: RuntimeWarning: invalid value encountered in less
  if __name__ == '__main__':
Out[33]:
objDECALSSDSS
333224_325
ra=354.030258984
dec=0.135485044552
r=20.7746353149
sb_r_0.5=21.495218277
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
333225_2208
ra=354.257459883
dec=0.201174686276
r=19.4929084778
sb_r_0.5=22.1104812622
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
333225_2208
ra=354.257459883
dec=0.201174686276
r=19.4929084778
sb_r_0.5=22.1104812622
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
333223_4126
ra=353.891410513
dec=0.294149517986
r=17.6671066284
sb_r_0.5=18.4971179962
decam_anymask=[0 0 0 0 1 0]
decam_allmask=[0 0 0 0 0 0]
334665_140
ra=354.352428456
dec=0.39355706821
r=20.3170337677
sb_r_0.5=22.5981121063
decam_anymask=[0 0 0 0 1 0]
decam_allmask=[0 0 0 0 0 0]
334665_140
ra=354.352428456
dec=0.39355706821
r=20.3170337677
sb_r_0.5=22.5981121063
decam_anymask=[0 0 0 0 1 0]
decam_allmask=[0 0 0 0 0 0]
333225_891
ra=354.397128257
dec=0.154697114542
r=20.7836914062
sb_r_0.5=21.8244113922
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
334665_5058
ra=354.292346591
dec=0.57973710936
r=20.6847515106
sb_r_0.5=22.7135047913
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
333225_2208
ra=354.257459883
dec=0.201174686276
r=19.4929084778
sb_r_0.5=22.1104812622
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
334664_6383
ra=354.073747792
dec=0.618836396717
r=20.6060733795
sb_r_0.5=21.7987117767
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
334665_140
ra=354.352428456
dec=0.39355706821
r=20.3170337677
sb_r_0.5=22.5981121063
decam_anymask=[0 0 0 0 1 0]
decam_allmask=[0 0 0 0 0 0]
333225_2825
ra=354.478620964
dec=0.226311697171
r=20.9204444885
sb_r_0.5=23.5217971802
decam_anymask=[0 1 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
333224_325
ra=354.030258984
dec=0.135485044552
r=20.7746353149
sb_r_0.5=21.495218277
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
331783_4208
ra=353.910583277
dec=0.0341764223467
r=20.5110683441
sb_r_0.5=21.5285301208
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
334665_140
ra=354.352428456
dec=0.39355706821
r=20.3170337677
sb_r_0.5=22.5981121063
decam_anymask=[0 0 0 0 1 0]
decam_allmask=[0 0 0 0 0 0]
334664_3718
ra=354.138032833
dec=0.51820672535
r=19.2125148773
sb_r_0.5=23.6868190765
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
333225_5297
ra=354.2696839
dec=0.313821173632
r=20.3451766968
sb_r_0.5=22.5209217072
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
331783_4208
ra=353.910583277
dec=0.0341764223467
r=20.5110683441
sb_r_0.5=21.5285301208
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
333225_891
ra=354.397128257
dec=0.154697114542
r=20.7836914062
sb_r_0.5=21.8244113922
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
334665_1294
ra=354.321116882
dec=0.432970176732
r=20.747051239
sb_r_0.5=23.7284755707
decam_anymask=[0 1 1 0 1 0]
decam_allmask=[0 0 0 0 0 0]
331783_4208
ra=353.910583277
dec=0.0341764223467
r=20.5110683441
sb_r_0.5=21.5285301208
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
334665_5058
ra=354.292346591
dec=0.57973710936
r=20.6847515106
sb_r_0.5=22.7135047913
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
334665_530
ra=354.493707267
dec=0.389694984786
r=20.9355335236
sb_r_0.5=23.2476825714
decam_anymask=[0 0 0 0 1 0]
decam_allmask=[0 0 0 0 0 0]
331783_4208
ra=353.910583277
dec=0.0341764223467
r=20.5110683441
sb_r_0.5=21.5285301208
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]
331785_2853
ra=354.362212893
dec=-0.00391007372437
r=20.8403205872
sb_r_0.5=21.9874038696
decam_anymask=[0 0 0 0 0 0]
decam_allmask=[0 0 0 0 0 0]

Interpolated SDSS-like SB

Important thing to understand here: this is not the same as the SDSS SB's for a subtle reason. The SDSS SB's are all from assuming an exponential profile. Here, instead (because DECaLS doesn't have the data for exp profiles if the object is not found to be exp type), we use an SB within either the exponential half-light radius, the de Vaucouleurs effective radius, or the seeing FWHM for exp galaxies, DeV galaxies, or PSF's, respectively.

The flux is also not the modeled flux, but rather an interpolated flux at that radius from the apertures.


In [34]:
plt.figure(figsize=(12, 10))

xnm = 'r'
ynm = 'sdss_like_sb_r'

dmextinction = -2.5*np.log10(dmatch['decam_mw_transmission'][:, 2])
x = dmatch[xnm] - dmextinction
y = dmatch[ynm] - dmextinction
dstar = dmatch['type']=='PSF '
sstar = smatch['phot_sg']==6


dnstar = dnomatch['type']=='PSF '
dnoext = -2.5*np.log10(dnomatch['decam_mw_transmission'][:, 2])
plt.scatter((dnomatch[xnm] - dnoext)[~dnstar], (dnomatch[ynm] - dnoext)[~dnstar], 
            c='k', lw=0, alpha=.25, label='Glx in DECALS, not in SDSS', marker='s')
plt.scatter((dnomatch[xnm] - dnoext)[dnstar], (dnomatch[ynm] - dnoext)[dnstar], 
            c='k', lw=0, alpha=.15, s=60, 
            label='Star in DECALS, not in SDSS', marker='*')

plt.scatter(x[dstar&sstar], y[dstar&sstar], c='m', lw=0, alpha=.25, s=60,
            label='Star in both', marker='*')

plt.scatter(x[~dstar&~sstar], y[~dstar&~sstar], c='b', lw=0, alpha=.25, label='Glx in Both')
plt.scatter(x[dstar&~sstar], y[dstar&~sstar], c='r', lw=0, alpha=.25, 
            label='Star in DECaLS, Glx in SDSS', marker='^', s=50)
plt.scatter(x[~dstar&sstar], y[~dstar&sstar], c='g', lw=0, alpha=.25, 
            label='Glx in DECaLS, Star in SDSS', marker='^', s=50)


plt.axvline(20.75, color='k', ls=':')

plt.xlim(17, 24.5)
plt.ylim(18, 30)

plt.xlabel(r'$r_{0, {\rm DECaLS}}$', fontsize=28)
plt.ylabel(r'$SB_{sdssish}, {\rm DECaLS}}$', fontsize=28)
plt.xticks(fontsize=24)
plt.yticks(fontsize=24)

plt.legend(loc='lower right', fontsize=20)

#change to "Should have only the Glx both, Glx D/not in S, and Gx D/star in S points"
#OUTPUT THESE DATA FOR MARLA,


Out[34]:
<matplotlib.legend.Legend at 0x1b20cd050>

Table to send to marla for further processing

Need to calculate the "dmag"'s - see "DECALS low-SB_completeness Residuals" notebook for more info on this


In [56]:
def extract_dmags(dcat):   
    apmag, apmagerr = fluxivar_to_mag_magerr(dcat['decam_apflux'], dcat['decam_apflux_ivar'])
    apmagres, _ = fluxivar_to_mag_magerr(dcat['decam_apflux_resid'], dcat['decam_apflux_ivar'])
    
    dmags = {}
    for band, ap in [('r', 1.0*u.arcsec), ('g', 1.0*u.arcsec), ('r', 5.0*u.arcsec), ('g', 5.0*u.arcsec)]:
        nm = 'dmagap_{}_{}asec'.format(band, ap.value)
        dmags[nm] = subselect_aperture(apmag, band, ap) - subselect_aperture(apmagres, band, ap)
    
    return dmags

First tabulate the match objects


In [59]:
to_send_to_marla = dmatch['ra', 'dec']
to_send_to_marla['r0'] = x
to_send_to_marla['r_err'] = dmatch['r_err']

to_send_to_marla['Rh_exp'] = dmatch['shapeExp_r']
to_send_to_marla['Rh_dev'] = dmatch['shapeDev_r']
to_send_to_marla['Rh_psf'] = dmatch['decam_psfsize']/2.

to_send_to_marla['sb_sdsslike'] = y

to_send_to_marla['id'] = ['{}_{}'.format(row['brickid'], row['objid']) for row in dmatch]
col = to_send_to_marla['id']
del to_send_to_marla['id']
to_send_to_marla.add_column(col, 0)
to_send_to_marla

to_send_to_marla['insdss'] = True
to_send_to_marla['star_decals'] = dstar
to_send_to_marla['star_sdss'] = sstar

for nm, arr in extract_dmags(dmatch).items():
    to_send_to_marla[nm] = arr


/Users/erik/miniconda3/envs/saga/lib/python2.7/site-packages/ipykernel/__main__.py:8: RuntimeWarning: invalid value encountered in subtract

Add in the no-match objects


In [60]:
toadd = dnomatch['ra', 'dec']
toadd['r0'] = dnomatch[xnm] - dnoext
toadd['r_err'] = dnomatch['r_err']

toadd['Rh_exp'] = dnomatch['shapeExp_r']
toadd['Rh_dev'] = dnomatch['shapeDev_r']
toadd['Rh_psf'] = dnomatch['decam_psfsize']/2.

toadd['sb_sdsslike'] = dnomatch[ynm] - dnoext
toadd.add_column(table.Column(name='id', data=['{}_{}'.format(row['brickid'], row['objid']) for row in dnomatch]), 
                 index=0)

toadd['insdss'] = False
toadd['star_decals'] = dnstar
toadd['star_sdss'] = False

for nm, arr in extract_dmags(dnomatch).items():
    toadd[nm] = arr

to_send_to_marla = table.vstack([to_send_to_marla, toadd])


/Users/erik/miniconda3/envs/saga/lib/python2.7/site-packages/ipykernel/__main__.py:8: RuntimeWarning: invalid value encountered in subtract

In [61]:
to_send_to_marla


Out[61]:
<Table length=317698>
idradecr0r_errRh_expRh_devRh_psf [6]sb_sdsslikeinsdssstar_decalsstar_sdssdmagap_g_1.0asecdmagap_r_1.0asecdmagap_g_5.0asecdmagap_r_5.0asec
degdegmagmagarcsecarcsecmag / arcsec2magmagmagmag
str11float64float64float32float32float32float32float32float64boolboolboolfloat32float32float32float32
333224_4195354.1515236970.28331365276121.92420.02539140.657560.00.0 .. 0.023.5558292046TrueFalseFalse-3.36565nannannan
333224_4070354.1116309920.28142554427221.67110.0184670.6993950.00.0 .. 0.023.1804827126TrueFalseFalsenannannannan
333224_4931354.1133006840.31492077918522.12640.0256240.2965630.00.0 .. 0.023.8890018083TrueFalseFalse-4.15724-4.79648nannan
333224_4632354.1571977280.2999422350122.42960.04090870.7341050.00.0 .. 0.024.1708053104TrueFalseTrue-2.54024-4.9516nannan
333224_4858354.1110548280.31327157416822.70170.04911330.00.3897810.0 .. 0.023.9001332966TrueFalseFalse-2.74265nannannan
333224_4808354.1069298560.30844022893822.18140.0276510.00.2623510.0 .. 0.023.4533167359TrueFalseFalse-3.20483-4.26994nannan
333224_4570354.1043472150.29666555290522.3740.03277330.6158190.00.0 .. 0.023.7514817362TrueFalseFalse-2.52538-4.3007nannan
333224_4397354.1034439330.28853059826923.1050.04864080.00.00.0 .. 0.024.9884184017TrueTrueFalse-3.26936-5.92542nannan
333224_5094354.1435561450.32309256780122.58690.03111190.00.00.0 .. 0.024.4569129795TrueTrueTruenannannannan
................................................
338986_2289354.5114226091.2195905884523.95370.1148480.300670.00.0 .. 0.024.5468670421FalseFalseFalse-1.59764nannannan
338986_2292354.5039841541.2199332042224.43930.2145910.450.00.0 .. 0.025.789053103FalseFalseFalse-0.701496-2.55405nannan
338986_2293354.5031191611.2197512498525.68910.5037340.00.00.0 .. 0.027.0310539077FalseTrueFalse-1.78863-1.4552nannan
338986_2351354.5097349941.2215752954523.61830.1614531.385850.00.0 .. 0.026.0880760312FalseFalseFalsenan-2.09192nannan
338986_2386354.5011652371.2236478308824.27670.1385480.00.00.0 .. 0.026.1525054622FalseTrueFalse-2.44356nannannan
338986_2417354.4959280471.2240305768425.05870.2836260.00.00.0 .. 0.027.0123539622FalseTrueFalse-2.26727-2.2486-2.21596nan
338986_2441354.4944028991.2253845863324.65630.1965850.00.00.0 .. 0.026.5928716753FalseTrueFalse-1.64198-3.51095nannan
338986_2443354.5025736831.2254657003924.61470.1888520.00.00.0 .. 0.026.927071341FalseTrueFalse-2.62005nannannan
338986_2482354.4952775931.2268978984123.57620.09755880.450.00.0 .. 0.025.1867564377FalseFalseFalse-1.20049nannannan
338986_2547354.4948237281.2286631503524.8750.2393780.00.00.0 .. 0.026.4918691329FalseTrueFalse-1.5423nannannan

In [63]:
to_send_to_marla.write('/Users/erik/Dropbox/SAGA/paper1_rvssb_data.fits.gz')

Gal type differences

The below plot is to see if there's significant differences between the two galaxy types, since their SB calculations are quite different


In [38]:
plt.figure(figsize=(12, 10))

xnm = 'r'
ynm = 'sdss_like_sb_r'

dmextinction = -2.5*np.log10(dmatch['decam_mw_transmission'][:, 2])
x = dmatch[xnm] - dmextinction
y = dmatch[ynm] - dmextinction
dstar = dmatch['type']=='PSF '
ddev = dmatch['type']=='DEV '
sstar = smatch['phot_sg']==6


dnstar = dnomatch['type']=='PSF '
dndev = dnomatch['type']=='DEV '
dnoext = -2.5*np.log10(dnomatch['decam_mw_transmission'][:, 2])

plt.scatter((dnomatch[xnm] - dnoext)[~dnstar&~dndev], (dnomatch[ynm] - dnoext)[~dnstar&~dndev], 
            c='g', lw=0, alpha=.15, label='Exp Glx in DECALS, not in SDSS', marker='*', s=40)
plt.scatter((dnomatch[xnm] - dnoext)[~dnstar&dndev], (dnomatch[ynm] - dnoext)[~dnstar&dndev], 
            c='k', lw=0, alpha=.15, label='DeV Glx in DECALS, not in SDSS', marker='^', s=30)

plt.scatter(x[~dstar&ddev], y[~dstar&ddev], c='b', lw=0, alpha=.15, 
            label='Exp Glx in DECaLS, in SDSS', marker='o', s=15)
plt.scatter(x[~dstar&~ddev], y[~dstar&~ddev], c='r', lw=0, alpha=.15, 
            label='DeV Glx in DECaLS, in SDSS', marker='s', s=20)




#plt.hlines(24.5, 17, 21, colors='k', linestyles='--')
plt.axvline(20.75, color='k', ls=':')

plt.xlim(17, 24.5)
plt.ylim(18, 30)

plt.xlabel(r'$r_{0, {\rm DECaLS}}$', fontsize=28)
plt.ylabel(r'$SB_{sdssish}, {\rm DECaLS}}$', fontsize=28)
plt.xticks(fontsize=24)
plt.yticks(fontsize=24)

plt.legend(loc='lower right', fontsize=20)


Out[38]:
<matplotlib.legend.Legend at 0x167590310>

Outputable figure


In [39]:
plt.figure(figsize=(12, 10))

xnm = 'r'
ynm = 'sdss_like_sb_r'

dmextinction = -2.5*np.log10(dmatch['decam_mw_transmission'][:, 2])
x = dmatch[xnm] - dmextinction
y = dmatch[ynm] - dmextinction
dstar = dmatch['type']=='PSF '
sstar = smatch['phot_sg']==6


dnstar = dnomatch['type']=='PSF '
dnoext = -2.5*np.log10(dnomatch['decam_mw_transmission'][:, 2])
plt.scatter((dnomatch[xnm] - dnoext)[~dnstar], (dnomatch[ynm] - dnoext)[~dnstar], 
            c='k', lw=0, alpha=.25, label='Glx in DECALS, not in SDSS', marker='s', s=10)
# plt.scatter((dnomatch[xnm] - dnoext)[dnstar], (dnomatch[ynm] - dnoext)[dnstar], 
#             c='k', lw=0, alpha=.15, s=60, 
#             label='Star in DECALS, not in SDSS', marker='*')

# plt.scatter(x[dstar&sstar], y[dstar&sstar], c='m', lw=0, alpha=.25, s=60,
#             label='Star in both', marker='*')

plt.scatter(x[~dstar&~sstar], y[~dstar&~sstar], c='b', lw=0, alpha=.25, label='Glx in Both', s=5)
# plt.scatter(x[dstar&~sstar], y[dstar&~sstar], c='r', lw=0, alpha=.25, 
#             label='Star in DECaLS, Glx in SDSS', marker='^', s=50)
plt.scatter(x[~dstar&sstar], y[~dstar&sstar], c='r', lw=0, alpha=.25, 
            label='Glx in DECaLS, Star in SDSS', marker='*', s=60)


plt.axvline(20.75, color='k', ls=':')

plt.xlim(17, 24.5)
plt.ylim(18, 30)

plt.xlabel(r'$r_{0, {\rm DECaLS}}$', fontsize=28)
plt.ylabel(r'$SB_{sdssish}, {\rm DECaLS}}$', fontsize=28)
plt.xticks(fontsize=24)
plt.yticks(fontsize=24)

plt.legend(loc='lower right', fontsize=20)

#plt.savefig(os.environ['HOME'] + '/Desktop/fig_decals.pdf')


Out[39]:
<matplotlib.legend.Legend at 0x1af200190>

Matched Magnitude-functions


In [40]:
plt.figure(figsize=(12, 10))

xnm = 'r'

dmextinction = -2.5*np.log10(dmatch['decam_mw_transmission'][:, 2])

dstar = dmatch['type']=='PSF '
sstar = smatch['phot_sg']==6

dnstar = dnomatch['type']=='PSF '
dnoext = -2.5*np.log10(dnomatch['decam_mw_transmission'][:, 2])

r_match = dmatch[xnm] - dmextinction
r_nomatch = dnomatch[xnm] - dnoext

r_both = np.concatenate((r_match, r_nomatch))
bothstar = np.concatenate((dstar, dnstar))


plt.hist(r_match[~dstar], histtype='step', color='b', range=(17, 25), bins=100, log=True)
plt.hist(r_both[~bothstar], histtype='step', color='k', range=(17, 25), bins=100, log=True)

plt.xlabel(r'$r_{0, {\rm DECaLS}}$', fontsize=28)
plt.ylabel(r'$n$', fontsize=28)
plt.xticks(fontsize=24)
plt.yticks(fontsize=24)

plt.tight_layout()


/Users/erik/miniconda3/envs/saga/lib/python2.7/site-packages/numpy/lib/function_base.py:583: RuntimeWarning: invalid value encountered in greater_equal
  keep = (tmp_a >= mn)
/Users/erik/miniconda3/envs/saga/lib/python2.7/site-packages/numpy/lib/function_base.py:584: RuntimeWarning: invalid value encountered in less_equal
  keep &= (tmp_a <= mx)

Check that photometry matches


In [96]:
sr = smatch['r']
dr = dmatch['r']

plt.scatter(sr, dr-sr)
plt.ylim(-1,2)


Out[96]:
(-1, 2)